import 'package:daoyi_ui_admin_getx/app/modules/home/home_recommend_data.dart';
import 'package:daoyi_ui_admin_getx/app/routes/app_pages.dart';
import 'package:daoyi_ui_admin_getx/generated/locales.g.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'home_recommend_item_widget.dart';

class HomeRecommendWidget extends StatelessWidget {
  final List<HomeRecommendData> dataList;

  const HomeRecommendWidget({super.key, this.dataList = homeRecommendData});

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(10),
      decoration: BoxDecoration(
        color: const Color(0x08000000),
        borderRadius: BorderRadius.circular(8),
      ),
      child: Column(
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              Text(
                LocaleKeys.pages_home_opensource_recommend.tr,
                style: const TextStyle(
                  fontSize: 16,
                  fontWeight: FontWeight.bold,
                ),
              ),
              TextButton(
                onPressed: () {
                  Get.toNamed(Routes.OPEN_SOURCE);
                },
                child: Text(
                  LocaleKeys.commons_more.tr,
                  style: const TextStyle(
                    color: Colors.black45,
                  ),
                ),
              ),
            ],
          ),
          const SizedBox(
            height: 10,
          ),
          Wrap(
            runSpacing: 10,
            spacing: 10,
            children: dataList
                .map(
                  (item) => HomeRecommendItemWidget(
                    item,
                    width: (MediaQuery.of(context).size.width - 10.0 * 3) / 2,
                  ),
                )
                .toList(),
          ),
        ],
      ),
    );
  }
}
